package com.hecore.lagou.mr.entity;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @Author: hecore
 * @Date: 2020/10/18 21:13
 * @Description:
 *  可以实现代码模版生成器
 */
// 1.1 实现Writable
public class PartitionBean implements Writable {


    // 1.3
    public void write(DataOutput output) throws IOException {
        output.writeUTF(id);
        output.writeUTF(deviceId);
        output.writeUTF(appKey);
        output.writeUTF(ip);
        output.writeLong(selfDuration);
        output.writeLong(thirdPartDuration);
        output.writeUTF(status);
    }

    // 1.4 反序列化
    public void readFields(DataInput input) throws IOException {
        this.id = input.readUTF();
        this.deviceId=input.readUTF();
        this.appKey=input.readUTF();
        this.ip=input.readUTF();
        this.selfDuration=input.readLong();
        this.thirdPartDuration=input.readLong();
        this.status=input.readUTF();
    }

    // 1.5 空参构造
    public PartitionBean() {
    }

    public PartitionBean(String id, String deviceId, String appKey, String ip, Long selfDuration, Long thirdPartDuration, String status) {
        this.id = id;
        this.deviceId = deviceId;
        this.appKey = appKey;
        this.ip = ip;
        this.selfDuration = selfDuration;
        this.thirdPartDuration = thirdPartDuration;
        this.status = status;
    }

    // 1.6 toString
    @Override
    public String toString() {
        return  id + '\t' +
                deviceId + '\t'  +
                appKey + '\t'  +
                ip + '\t' +
                selfDuration  + '\t' +
                thirdPartDuration  + '\t' +
                status;
    }

    // 1.2 属性定义
    private String id;

    private String deviceId;

    private String appKey;

    /**
     * ip地址
     */
    private String ip;

    private Long selfDuration;

    private Long thirdPartDuration;

    private String status;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getAppKey() {
        return appKey;
    }

    public void setAppKey(String appKey) {
        this.appKey = appKey;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Long getSelfDuration() {
        return selfDuration;
    }

    public void setSelfDuration(Long selfDuration) {
        this.selfDuration = selfDuration;
    }

    public Long getThirdPartDuration() {
        return thirdPartDuration;
    }

    public void setThirdPartDuration(Long thirdPartDuration) {
        this.thirdPartDuration = thirdPartDuration;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }


}
